var express = require('express');
var path = require('path');
var favicon = require('static-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var bodyParser = require('body-parser');
var http = require('http');

var setting = require('./setting');
var index = require('./routes/index');
var user = require('./routes/user');
var project = require('./routes/project');
var broadcast = require('./routes/broadCast');
var comment = require('./routes/comment');
var course = require('./routes/course');
var trainpoint = require('./routes/trainPoint');
var direction = require('./routes/direction');
var examine = require('./routes/examine');
var feedback = require('./routes/feedback');
var message = require('./routes/message');
var report = require('./routes/report');
var teacher = require('./routes/teacher');
var errset = require('./routes/errset');
var copy_data = require('./routes/copy_data');
var filter = require('./filter');

var app = express();
app.set('port', 7000);
//app.set('port', 80);
app.use(favicon());
app.use(logger('dev'));
app.use(bodyParser.json({
	limit: '200mb'
}));
app.use(bodyParser.urlencoded({
	limit: '200mb',
	extended: true
}));

app.use(cookieParser("test"));
app.use("/", filter);
app.use("/", index);
app.use("/", copy_data);

app.use(express.static(path.join(__dirname, '../onlinelearning2_w/web/')));

app.use("/user", user);
app.use("/project", project);
app.use("/trainpoint", trainpoint);
app.use("/broadcast", broadcast);
app.use("/comment", comment);
app.use("/course", course);
app.use("/direction", direction);
app.use("/examine", examine);
app.use("/feedback", feedback);
app.use("/message", message);
app.use("/report", report);
app.use("/teacher", teacher);
app.use("/errset", errset);
/// catch 404 and forwarding to error handler


app.listen(app.get("port"), function() {
	console.log(app.get("port"));
});